package com.iflysse.dao;

import com.iflysse.pojo.po.resp.QuestionPoResp;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.sql.SQLException;
import java.util.List;

@Repository
public interface QuestionDao {
    /**
     * 根据3级知识点获取问题
     * @param knowledgePointId 3级知识点编号
     * @return
     */

    @Select({"select * from tb_question where knowledge_point_id = #{knowledgePointId}"})
    @Results({
            @Result(property = "questionId",column = "question_id"),
            @Result(property = "knowledgePointId",column = "knowledge_point_id"),
            @Result(property = "questionType",column = "question_type"),
            @Result(property = "difficultyLevel",column = "difficulty_level"),
            @Result(property = "questionContent",column = "question_content"),
    })
    List<QuestionPoResp> getQuestionByKnowledgePointId(String knowledgePointId) throws SQLException;


    /**
     * 根据问题编号获取问题详情
     * @param questionId 问题编号
     * @return 问题
     */
    @Select({"select * from tb_question where question_id = #{questionId}"})
    @Results({
            @Result(property = "questionId",column = "question_id"),
            @Result(property = "knowledgePointId",column = "knowledge_point_id"),
            @Result(property = "questionType",column = "question_type"),
            @Result(property = "difficultyLevel",column = "difficulty_level"),
            @Result(property = "questionContent",column = "question_content"),
    })
    public QuestionPoResp getQuestionByQuestionId(String questionId) throws SQLException;


    /**
     * 根据问题编号列表,获取问题详情列表
     * @param questionIdS
     * @return
     */
    @Select( " <script>" +
            "select * from tb_question where question_id in  " +
            " <foreach collection='questionIdS' open='(' item='questionId' separator=',' close=')'> #{questionId}</foreach> "+
            " </script>" )
    @Results({
            @Result(property = "questionId",column = "question_id"),
            @Result(property = "knowledgePointId",column = "knowledge_point_id"),
            @Result(property = "questionType",column = "question_type"),
            @Result(property = "difficultyLevel",column = "difficulty_level"),
            @Result(property = "questionContent",column = "question_content"),
    })
    public List<QuestionPoResp> getQuestionListByQuestionIds(List<String> questionIdS) throws SQLException;
}
